<?php

/**
 * ConceptoCf form.
 *
 * @package    cronos-doctrine
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ConceptoCfForm extends BaseConceptoCfForm
{
  public function configure()
  {
      
       unset(
          $this['created_at'],
          $this['updated_at']
      );
      
     
       $this->widgetSchema['empresa_id'] = new sfWidgetFormInputHidden(array(),array('value'=> sfContext::getInstance()->getUser()->getAttribute('agente_user_empresa_id')));
       
       
      $this->widgetSchema['status'] = new sfWidgetFormChoice(array(
         'choices' => ConceptoCf::$status,
         'expanded' => false,
         'multiple' => false,

      ));
      
      //Cambiar a lista de padres
      $this->widgetSchema['tipo_concepto_cf_id'] = new sfWidgetFormDoctrineChoice(array(
          'model' => 'TipoConceptoCf',
          'method' => 'getNombre',
          'order_by' => array('nombre', 'asc'),
          'expanded' => false,
          'multiple' => false,
      ));
      
      $this->widgetSchema['nombre'] = new sfWidgetFormInputText(array(),array('placeholder'=>'Nombre Producto', 'style'=>'width:350px;'));
     
          
     //Monto del Concepto
      $unions = $this->getObject()->getConceptoCfHasEmpresa();
      
      if(!count($unions)) {
          $unions = array();
      }
      $unions_form = new sfForm();
      $count = 0;
      
      if($this->isNew()){
          
          $union = new ConceptoCfHasEmpresa();
          $union->ConceptoCf = $this->getObject();
          $union_form = new ConceptoCfHasEmpresaForm($union);
          $unions_form->embedForm(0, $union_form);
          
      }else{
        
          foreach ($unions as $union){
            
            $union_form = new ConceptoCfHasEmpresaForm($union);
            $unions_form->embedForm($count, $union_form);
            $count++;
        }
        
      }

    
      $this->embedForm('union', $unions_form);
      // Fin //Monto del Concepto
         
   
      
  }
}
